import {Component, EventEmitter, Injector, OnInit, Output} from '@angular/core';
import {EmployeeServiceSvr} from '../../../services/employee.service';
import {CoreComponent} from 'pengesoft-ng-lib';

@Component({
  selector: 'app-detail-files',
  templateUrl: './detail-files.component.html',
  styleUrls: ['./detail-files.component.less']
})
export class DetailFilesComponent extends CoreComponent implements OnInit {

  @Output() cancelDetailFileShowModal = new EventEmitter();

  // tslint:disable-next-line:max-line-length
  acceptEmployee: { EmergencyContact: string; ExtAttr: string; Sex: number; StateId: string; JobName: string; CardAddress: string; CardNum: string; EmployeeDay: number; Birth: Date | string; Politic: string; Name: string; EmergencyPeople: string; CardType: string; Phone: string; DeptName: string; ArchivesFile: string; Age: number; JobId: string; StudyMajor: string; NativePlace: string; IDCard: string; IDPlace: string; NowPlace: string; EducationLevel: string; ArchivesNum: string; Id: string; GraduatedSchool: string; GraduatedTime: Date | string; HouseholdType: string };

  constructor(private injector: Injector,
              private employSvr: EmployeeServiceSvr) {
    super(injector);
  }

  ngOnInit(): void {
    this.employSvr.getArchivesByEmpId(window.sessionStorage.getItem('sendEnterFilesID')).then(res => {
      this.acceptEmployee = {
        DeptName: res.EmployeeDto.DeptName,
        Age: res.EmployeeDto.Employee.Age,
        ArchivesFile: res.EmployeeDto.Employee.ArchivesFile,
        ArchivesNum: res.EmployeeDto.Employee.ArchivesNum,
        Birth: res.EmployeeDto.Employee.Birth,
        CardAddress: res.EmployeeDto.Employee.CardAddress,
        CardNum: res.EmployeeDto.Employee.CardNum,
        CardType: res.EmployeeDto.Employee.CardType,
        EducationLevel: res.EmployeeDto.Employee.EducationLevel,
        EmergencyContact: res.EmployeeDto.Employee.EmergencyContact,
        EmergencyPeople: res.EmployeeDto.Employee.EmergencyPeople,
        EmployeeDay: res.EmployeeDto.Employee.EmployeeDay,
        ExtAttr: res.EmployeeDto.Employee.ExtAttr,
        GraduatedSchool: res.EmployeeDto.Employee.GraduatedSchool,
        GraduatedTime: res.EmployeeDto.Employee.GraduatedTime,
        HouseholdType: res.EmployeeDto.Employee.HouseholdType,
        IDCard: res.EmployeeDto.Employee.IDCard,
        IDPlace: res.EmployeeDto.Employee.IDPlace,
        Id: res.EmployeeDto.Employee.Id,
        JobId: res.EmployeeDto.Employee.JobId,
        Name: res.EmployeeDto.Employee.Name,
        NativePlace: res.EmployeeDto.Employee.NativePlace,
        NowPlace: res.EmployeeDto.Employee.NowPlace,
        Phone: res.EmployeeDto.Employee.Phone,
        Politic: res.EmployeeDto.Employee.Politic,
        Sex: res.EmployeeDto.Employee.Sex,
        StateId: res.EmployeeDto.Employee.StateId,
        StudyMajor: res.EmployeeDto.Employee.StudyMajor,
        JobName: res.EmployeeDto.JobName
      };
    });
  }

  // 点击返回
  back(): void {
    this.cancelDetailFileShowModal.emit();
    window.sessionStorage.setItem('index', '-1');
  }

}
